package com.vivo.toolkit.stringtoolkit;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ModelUtil {
	public static void print(Object o) {
		System.out.println("====Model util  print : " + o.getClass().getName()
		        + "===============");

		if (o == null) {
			System.out.println("Model util Error : print a null object;");
		}
		Method[] methods = o.getClass().getDeclaredMethods();
		try {
			for (Method method : methods) {
				if (method.getName().startsWith("get")) {
					System.out.println(method.getName() + " : " + method.invoke(o, null));
				}
			}
		} catch (IllegalArgumentException e) {
		} catch (IllegalAccessException e) {
		} catch (InvocationTargetException e) {
		}

		System.out.println("============== END ==============");

		// Field[] fileds = o.getClass().getDeclaredFields();

		// for (Field field : fileds) {
		// try {
		// System.out.println(field.getName()+" : " + field.get(o));
		// } catch (IllegalArgumentException e) {
		// } catch (IllegalAccessException e) {
		// }
		// }
	}

	public static void main(String[] a) {

		A as = new ModelUtil.A();

		ModelUtil.print(as);
	}

	static class A {
		private A() {

		}
		private int a = 0;
		private String b = "sdf";
		public int c = 0;

		public int getA() {
			return a;
		}

		public String getB() {
			return b;
		}

		public int getC() {
			return c;
		}

		public void setA(int a) {
			this.a = a;
		}

		public void setB(String b) {
			this.b = b;
		}

		public void setC(int c) {
			this.c = c;
		}

	}

}
